package com.example.demo.dataobject;

import com.example.demo.model.ProductDetail;

import java.time.LocalDateTime;

/**
 * 商品详情数据库对象
 */
public class ProductDetailDO {
    private String id;//主键
    private String productId;//关联商品
    private Double price;//价格
    private Double size;//尺码
    private Integer stock;//库存
    private LocalDateTime gmtCreated;//创建时间
    private LocalDateTime gmtModified;//修改时间

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Double getSize() {
        return size;
    }

    public void setSize(Double size) {
        this.size = size;
    }

    public Integer getStock() {
        return stock;
    }

    public void setStock(Integer stock) {
        this.stock = stock;
    }

    public LocalDateTime getGmtCreated() {
        return gmtCreated;
    }

    public void setGmtCreated(LocalDateTime gmtCreated) {
        this.gmtCreated = gmtCreated;
    }

    public LocalDateTime getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(LocalDateTime gmtModified) {
        this.gmtModified = gmtModified;
    }

    /**
     * 数据库对象转换成模型
     * @return ProductDetail商品详情模型
     */
    public ProductDetail toModel() {
        ProductDetail model = new ProductDetail();
        model.setId(id);
        model.setProductId(productId);
        model.setPrice(price);
        model.setSize(size);
        model.setStock(stock);
        model.setGmtCreated(gmtCreated);
        model.setGmtModified(gmtModified);
        return model;
    }
}
